Skip to content

UpDownBase: Fix event subscription mismatch #3844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
Merged

UpDownBase: Fix event subscription mismatch #3844

merged 2 commits into from
May 9, 2025

Conversation

nicolaihenriksen
Copy link
Contributor

@nicolaihenriksen nicolaihenriksen commented May 2, 2025

Fixes #3827

UPDATE

Ooh, a failing test! It seems there is a requirement to revert back to original value on LostFocus if the entered value is invalid...
Not entirely sure how to handle that use-case, while still supporting UpdateSourceTrigger=PropertyChanged 🤔


The UpDownBase was only subscribing to the LostFocus event, but the unsubscribing the TextChanged event. This is a potential event-handler leak, but also the root cause of the reported issue.

This PR ensures only the TextChanged event is subscribed/unsubscribed, and then let's the internal binding system handle when to notify a bound view model property. As long as we call SetCurrentValue() for the "most frequent update source trigger", the built-in system will handle the rest for us (I am quite sure of).

@nicolaihenriksen nicolaihenriksen added this to the 5.3.0 milestone May 2, 2025
Fixes an issue where the NumericUpDown control was not properly updating the text in the TextBox when focus was lost after invalid input.
Adds a LostFocus event handler to update the textbox value.
Adds UI tests to verify that values are updated as expected.
@Keboo Keboo enabled auto-merge (squash) May 9, 2025 05:43
@Keboo Keboo merged commit f5a504d into master May 9, 2025
2 checks passed
@Keboo Keboo deleted the fix3827 branch May 9, 2025 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NumericUpdown not notifying UpdateSourceMode=PropertyChanged
2 participants